import { batch } from "react-redux";
import request from "../utils/request";

// 添加角色
export const roleAdd = (roleInfo) => {
  return request.post("classes/roleData", roleInfo);
};
// 获取角色
export const roleLook = (roleid) => {
  const id = roleid ? `/${roleid}` : "";
  return request.get(`classes/roleData${id}`);
};

// 更新角色
export const roleUpdate = (id, roleInfo) => {
  return request.put(`classes/roleData/${id}`, roleInfo);
};

// 删除角色
export const roleDel = (id) => {
  return request.delete(`classes/roleData/${id}`);
};

// 批量删除
export const roleBatchDel = (ids) => {
  const requests = ids.map((item) => {
    return {
      method: "DELETE",
      path: `/1.1/classes/roleData/${item}`,
    };
  });
  return request.post("batch", { requests });
};
